package com.flyme.module.base.provider.controller;

import com.flyme.common.core.model.ResultBody;
import com.flyme.common.core.model.query.CriteriaQuery;
import com.flyme.common.core.model.query.PagerInfo;
import com.flyme.common.core.model.query.PqGrid;
import com.flyme.core.base.supper.controller.BaseController;
import com.flyme.core.base.supper.entity.EntityMap;
import com.flyme.module.base.client.entity.SysBlacklist;
import com.flyme.module.base.client.entity.SysUser;
import com.flyme.module.base.provider.service.SysBlacklistService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 黑名单管理
 *
 * @author zyf
 */
@Api(tags = "黑名单管理")
@RestController
public class SysBlackListController extends BaseController<SysBlacklistService, SysBlacklist> {


    /**
     * 黑名单管理
     *
     * @return
     */
    @ApiOperation(value = "黑名单", notes = "黑名单")
    @PostMapping("/blacklist/blacklistList")
    public ResultBody list(@ModelAttribute PagerInfo pagerInfo, @ModelAttribute SysUser user) {
        CriteriaQuery cq = new CriteriaQuery<EntityMap>(pagerInfo);
        cq.select("b.id,user.avatar,user.userName,company.compName,b.createTime");
        cq.like("userName", user.getUserName());
        cq.createAlias("user", "user");
        cq.createAlias("company", "company");
        PqGrid pqGrid = bizService.pageList(cq);
        return ResultBody.success(pqGrid);
    }


}
